package com.bawei.router

import android.content.Context
import com.alibaba.android.arouter.facade.Postcard
import com.alibaba.android.arouter.facade.annotation.Interceptor
import com.alibaba.android.arouter.facade.callback.InterceptorCallback
import com.alibaba.android.arouter.facade.template.IInterceptor
import com.bawei.base.path.RoutePath
import com.tencent.mmkv.MMKV

/**
 * Author: Jason Zhang
 * Date: 2025/4/24
 * Desc: 参数路由拦截器
 */

@Interceptor(priority = 5, name = "路由参数拦截器")
class RouteParamsInterceptor : IInterceptor{
    private lateinit var mContext: Context

    override fun init(context: Context?) {
        if (context != null){
            mContext = context
        }
    }

    override fun process(postcard: Postcard, callback: InterceptorCallback) {
        val accessId = MMKV.defaultMMKV().decodeString("accessId", "park_accessId")
        if (!accessId.isNullOrEmpty()) {
            postcard.withString("accessId", accessId)
        }
        callback.onContinue(postcard)
    }


}